<script type="text/javascript" language="javascript" charset="utf-8">
$(".menu-wrap li").removeClass("active-link");
$(".menu-wrap #teacher").addClass("active-link");
</script>
<!-- 内容区域 -->
<div class="common-tit">
  <h2>导师列表</h2>
  <span>导师管理 > 导师列表</span>
</div>
<div class="cur-list">
  <div class="cur-listbox clearfix">
    <div class="cur-ll cur-serch clearfix">
      <div class="list-box">
        <div class="downbtn">
          <span>性别</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="undefined">性别</li>
          <li data_id="男">男</li>
          <li data_id="女">女</li>
        </ul>
      </div>
      <div class="list-box">
        <div class="downbtn">
          <span>授课对象</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="undefined">授课对象</li>
          <% for key in @teaching_object.keys %>
          <li data_id="<%= @teaching_object[key] %>"><%= @teaching_object[key] %></li>
          <% end %>
        </ul>
      </div>
      <div class="list-box">
        <div class="downbtn">
          <span>导师等级</span>
          <em></em>
        </div>
        <ul class="dropdown-menu">
          <li data_id="undefined">导师等级</li>
          <% for teacher_level  in @teacherLevels %>
          <li data_id="<%= teacher_level.teacher_level %>"><%= teacher_level.teacher_level %></li>
          <% end %>
        </ul>
      </div>
      <div class="i-search">
        <form class="form-inline" action="/admin/teachers/get_teacher_by_name_phone" accept-charset="UTF-8" method="get">
          <em></em>
          <input type="text" name="q" id="q" class="form-control input-sm" placeholder="请输入要搜索导师的手机或名字"  />
        </form>
      </div>
      
      <!-- TODO：后面优化页面结构 -->
      <!-- <div class="pull-right"><form class="form-inline" action="/admin/teachers" accept-charset="UTF-8" method="get"><input type="text" name="q" id="q" class="form-control input-sm" placeholder="主页面刷新" /></form></div> -->

    </div>
  </div>
  <div class="curlist-con">
    <div class="scrollbox">
      <table>
        <thead>
          <tr>
            <th class="tea-head">头像</th>
            <th class="tea-name">姓名</th>
            <th class="tea-sex">性别</th>
            <th class="tea-obj">授课对象</th>
            <th class="tea-t">导师等级</th>
            <th class="curl-operation">操作</th>
          </tr>
        </thead>
        <tbody>

          <!-- 导师列表查询模块 kevin-->
          <% if @teachers %>
            <% @teachers.each do |teacher| %>
              <tr>
                <td>
                  <div class="as-imgbox">
                    <img src="" alt="">
                  </div>
                </td>
                <td><%= teacher["name"] %></td>
                <td><%= teacher["sex"] %></td>
                <td><%= teacher["age_group"] %></td>
                <td><%= teacher["teacher_level"] %></td>
                <td class="curl-operation">
                  <span>[</span>
                  <em><%= link_to "查看课表", admin_teacher_path(teacher["id"],name: teacher["name"]) %></em>
                  <span>]</span>
                  
                  <!-- 前台权限控制 flydragon -->
                  <% if !current_user.is_receptionist? %>
                    <span>[</span>
                    <em><%= link_to "授课学员", :action => "get_my_students_by_teacher_id", :teacher_id => teacher["id"], :name => teacher["name"] %></em>
                    <span>]</span>

                    <span>[</span>
                    <em><%= link_to "查看记录", :action => "get_my_record_teaching_salary", :teacher_id => teacher["id"], :name => teacher["name"] %></em>
                    <span>]</span>
                  <% end %>
                </td>
              </tr>
            <% end %>
          <% end %>   

        </tbody>
      </table>
    </div>
  </div>
</div>
<script src="/assets/js/common.js"></script>
<script>
//三个下拉筛选框处理
$(".cur-ll .list-box li").on("click", function() {
  $(this).parent().parent().find("span").attr("data_id", $(this).attr("data_id"));
  transData();
});
function transData() {
  // 性别，授课对象，导师等级
  var teacher_search = "";
  for (var i = 0; i < $(".cur-ll .list-box").length; i++) {
    var teacher_search_type = $($(".cur-ll .list-box")[i]).find("span").attr("data_id");
    switch(true) {
      case i == 0:{
        var tmp = "sex=" + teacher_search_type;
        teacher_search += tmp;
        break;
      }
      case i == 1:{
        var tmp = "&teaching_object=" + teacher_search_type;
        teacher_search += tmp;
        break;
      } 
      case i == 2:{
        var tmp = "&teacher_level=" + teacher_search_type;
        teacher_search += tmp;
        break;
      } 
    };
  };
  $.ajax({
    type:'get', url:"/admin/teachers/get_teacher_search_out?"+ teacher_search,
    success: function(data) {
      if (data.error) {
        // console.log("wrong");
      }
    }
  });
};
</script>
